package com.zyh.thread.demo6;

/**
 * @Author zyh
 * @Date 2024/8/8 14:43
 * @Description 生产者和消费者的演示
 */

public class ThreadDemo6 {
    public static void main(String[] args) {
        //创建商品对象
        Product product = new Product();
        //创建桌子对象
        Stack stack = new Stack(product, false);
        //创建生产者和消费者任务
        MyTask01 myTask01 = new MyTask01(stack);
        MyTask02 myTask02 = new MyTask02(stack);
        Thread t1 = new Thread(myTask01, "生产者A");
        Thread t2 = new Thread(myTask02, "消费者A");
        Thread t3 = new Thread(myTask01, "生产者B");
        Thread t4 = new Thread(myTask02, "消费者B");
        t1.start();
        t2.start();
        t3.start();
        t4.start();
    }
}
